import { MciTable, MciTableColumn } from '@/components/base';
import { useDictStore } from '@/store/dict';
import { TVariables } from '@/utils/graph';
import { PropType } from 'vue';

export const FieldsDataTable = defineComponent({
  props: {
    data: {
      type: Array as PropType<TVariables[]>,
      default: () => []
    }
  },
  setup(props, { slots }) {
    const dictStore = useDictStore();
    return () => {
      return (
        <MciTable data={props.data || []}>
          <MciTableColumn label="字段名称" prop="varName" />
          <MciTableColumn label="字段解释" prop="varLabel" />
          <MciTableColumn label="类型" prop="varType">
            {(scope: any) => <p>{dictStore.fieldTypeMap[scope.row.varType!]}</p>}
          </MciTableColumn>
          {slots.default?.()}
        </MciTable>
      );
    };
  }
});
